/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package src.com.dados;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author Adriano
 */
 
public class Conexao {
    private static Conexao instance;
    private Connection con;
 
    public Connection getCon() {
        return con;
    }
 
    public void setCon(Connection con) {
        this.con = con;
    }
 
    private Conexao() {
        this.execute();
    }
 
    public static Conexao getInstance() {
        if (instance == null) {
            instance = new Conexao();
        }
        return instance;
    }
 
    private Connection execute() {
        try {
            String url = "jdbc:mysql://localhost:3306/bdeng2";
            String usuario = "root";
            String senha = "dados";
            Class.forName("com.mysql.jdbc.Driver");
            this.setCon(DriverManager.getConnection(url, usuario, senha));
            System.out.println("Conexão realizada com sucesso.");
        } catch (Exception e) {
        }
        return con;
    }
}
 



